import React, { Component } from 'react'
import axios from 'axios'

export default class App extends Component {
	render() {
		return (
			<div>
				<h2>我是App组件</h2>
				<button onClick={this.getStudentInfo}>点我获取学生数据</button>
				<button onClick={this.getCarInfo}>点我获取汽车数据</button>
			</div>
		)
	}
	getStudentInfo = ()=>{
		axios.get('http://localhost:3000/demo/students').then(
			(response)=>{
				console.log('请求成功了',response.data)
			},
			(error)=>{
				console.log('请求失败了',error)
			}
		)
	}
	getCarInfo = ()=>{
		axios.get('http://localhost:3000/test/cars').then(
			(response)=>{
				console.log('请求成功了',response.data)
			},
			(error)=>{
				console.log('请求失败了',error)
			}
		)
	}
}
